<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var names = [
        "高宏元",
        "潘俊雄",
        "李凌君",
        "董含超",
        "王晓婷",
        "焦汉龙",
        "李成泽",
        "王志文",
        "李家豪",
        "易家平",
        "刘礼炎",
        "刘赞",
        "张艺伟",
        "马飞",
        "郭晨昕",
        "刘文杰",
        "关浩",
        "康鼎皓",
        "门欣冉",
        "颜含笑",
      ];
      var addname = [];

      function lottery(str, num1, num2, num3) {
        //num1,num2,num3:一等奖人数，二等奖人数，三等奖人数
        var list = ["一等奖：", "二等奖：", "三等奖："];
        var sum = num1 + num2 + num3;
        for (var i = 0; i < sum; i++) {
          var mr = parseInt(Math.random() * str.length);
          addname.push(str.splice(mr, 1));
        }
        for (var i = 0; i < sum; i++) {
          if (i <= num1) {
            document.write(list[0] + addname[i] + "<br>");
          } else if (i > num1 && i <= num1 + num2) {
            document.write(list[1] + addname[i] + "<br>");
          } else {
            document.write(list[2] + addname[i] + "<br>");
          }
        }
      }
      lottery(names, 1, 2, 3);
    </script>
  </body>
</html>
